/* 
	封装本地存储模块
*/

// 存储本地存储数据
export const setItem = (key,val) => {
	if (typeof val === 'object') {
		val = JSON.stringify(val)
	}
	localStorage.setItem(key,val)
}

// 获取本地存储模块
export const getItem = key => {
	const data = localStorage.getItem(key)
	try {
		return JSON.parse(data)
	} catch (error) {
		return data
	}
}

// 删除本地存储
export const removeItem = key => {
	localStorage.removeItem(key)
}